{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# optshare example"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [],
   "source": [
    "import optshare"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## Option data"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 返回当前场内期权数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                代码               名称   最新价    涨跌额      涨跌幅     成交量       成交额  \\\n",
      "0       a2305p4500    豆一23年05月沽4500  50.0   49.5  9900.00     1.0     500.0   \n",
      "1        i2305p510    铁矿石23年05月沽510   3.0    2.9  2900.00     1.0     300.0   \n",
      "2       v2305c9000   PVC23年05月购9000  12.5   12.0  2400.00     4.0     247.0   \n",
      "3       v2305c9200   PVC23年05月购9200  12.0   11.5  2300.00    23.0    1280.0   \n",
      "4      p2305c12600  棕榈油23年05月购12600   9.5    9.0  1800.00  2407.0  197575.0   \n",
      "...            ...              ...   ...    ...      ...     ...       ...   \n",
      "11963   y2303p8100    豆油23年03月沽8100   0.5   -2.0   -80.00   133.0    1135.0   \n",
      "11964   y2303p8400    豆油23年03月沽8400   3.0  -13.5   -81.82   942.0   46570.0   \n",
      "11965   SR303P5400    白糖23年03月沽5400   0.5   -2.5   -83.33   656.0    6560.0   \n",
      "11966   y2303p8300    豆油23年03月沽8300   1.5   -8.0   -84.21   874.0   19995.0   \n",
      "11967   v2309c7000   PVC23年09月购7000  40.0 -312.5   -88.65     1.0     200.0   \n",
      "\n",
      "           持仓量  行权价  剩余日      日增     昨结    今开  \n",
      "0        183.0  NaN  NaN     0.0    0.5  50.0  \n",
      "1        745.0  NaN  NaN     0.0    0.1   3.0  \n",
      "2        211.0  NaN  NaN     0.0    0.5  12.0  \n",
      "3        133.0  NaN  NaN    -7.0    0.5  10.5  \n",
      "4      12173.0  NaN  NaN  1360.0    0.5   7.0  \n",
      "...        ...  ...  ...     ...    ...   ...  \n",
      "11963    742.0  NaN  NaN   -80.0    2.5   1.0  \n",
      "11964    630.0  NaN  NaN   148.0   16.5   6.5  \n",
      "11965   5193.0  NaN  NaN   -82.0    3.0   0.5  \n",
      "11966   7134.0  NaN  NaN   -32.0    9.5   3.5  \n",
      "11967      9.0  NaN  NaN     0.0  352.5  40.0  \n",
      "\n",
      "[11968 rows x 13 columns]\n"
     ]
    }
   ],
   "source": [
    "current_option_df = optshare.get_current_option()\n",
    "print(current_option_df)"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 指定交易所名称，返回当前交易所的期权数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "data": {
      "text/plain": "                代码                名称  最新价  涨跌额      涨跌幅  成交量      成交额   持仓量  \\\n0    IO2301-P-3800   沪深300沽23年1月3800  0.4  0.2   100.0%   12    480.0  3748   \n1    IO2301-P-3850   沪深300沽23年1月3850  0.4  0.2   100.0%    7    280.0  2458   \n2    HO2301-P-2425    上证50沽23年1月2425  0.4  0.2   100.0%    6    240.0   530   \n3    MO2301-C-7000  中证1000购23年1月7000  1.4  0.6    75.0%    9    960.0  1151   \n4    MO2301-C-6900  中证1000购23年1月6900  1.8  0.6    50.0%   64  12300.0  1125   \n..             ...               ...  ...  ...      ...  ...      ...   ...   \n681  HO2301-P-2750    上证50沽23年1月2750  1.0 -0.6   -37.5%   16   1800.0  1577   \n682  IO2301-P-4050   沪深300沽23年1月4050  1.6 -1.0  -38.46%   53   7580.0  2628   \n683  MO2301-P-5500  中证1000沽23年1月5500  0.2 -0.2   -50.0%    1     20.0   142   \n684  HO2301-P-2700    上证50沽23年1月2700  0.2 -0.2   -50.0%   20    400.0  2013   \n685  MO2301-P-6300  中证1000沽23年1月6300  0.6 -0.6   -50.0%   16    680.0  1918   \n\n        行权价  剩余日  日增   昨结   今开  \n0    3800.0    2   6  0.2  0.4  \n1    3850.0    2   2  0.2  0.4  \n2    2425.0    2   6  0.2  0.4  \n3    7000.0    2   0  0.8  0.8  \n4    6900.0    2  -3  1.2  1.8  \n..      ...  ...  ..  ...  ...  \n681  2750.0    2  -6  1.6  1.4  \n682  4050.0    2 -27  2.6  1.6  \n683  5500.0    2   0  0.4  0.2  \n684  2700.0    2 -20  0.4  0.2  \n685  6300.0    2  -2  1.2  0.4  \n\n[686 rows x 13 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>代码</th>\n      <th>名称</th>\n      <th>最新价</th>\n      <th>涨跌额</th>\n      <th>涨跌幅</th>\n      <th>成交量</th>\n      <th>成交额</th>\n      <th>持仓量</th>\n      <th>行权价</th>\n      <th>剩余日</th>\n      <th>日增</th>\n      <th>昨结</th>\n      <th>今开</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>IO2301-P-3800</td>\n      <td>沪深300沽23年1月3800</td>\n      <td>0.4</td>\n      <td>0.2</td>\n      <td>100.0%</td>\n      <td>12</td>\n      <td>480.0</td>\n      <td>3748</td>\n      <td>3800.0</td>\n      <td>2</td>\n      <td>6</td>\n      <td>0.2</td>\n      <td>0.4</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>IO2301-P-3850</td>\n      <td>沪深300沽23年1月3850</td>\n      <td>0.4</td>\n      <td>0.2</td>\n      <td>100.0%</td>\n      <td>7</td>\n      <td>280.0</td>\n      <td>2458</td>\n      <td>3850.0</td>\n      <td>2</td>\n      <td>2</td>\n      <td>0.2</td>\n      <td>0.4</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>HO2301-P-2425</td>\n      <td>上证50沽23年1月2425</td>\n      <td>0.4</td>\n      <td>0.2</td>\n      <td>100.0%</td>\n      <td>6</td>\n      <td>240.0</td>\n      <td>530</td>\n      <td>2425.0</td>\n      <td>2</td>\n      <td>6</td>\n      <td>0.2</td>\n      <td>0.4</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>MO2301-C-7000</td>\n      <td>中证1000购23年1月7000</td>\n      <td>1.4</td>\n      <td>0.6</td>\n      <td>75.0%</td>\n      <td>9</td>\n      <td>960.0</td>\n      <td>1151</td>\n      <td>7000.0</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0.8</td>\n      <td>0.8</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>MO2301-C-6900</td>\n      <td>中证1000购23年1月6900</td>\n      <td>1.8</td>\n      <td>0.6</td>\n      <td>50.0%</td>\n      <td>64</td>\n      <td>12300.0</td>\n      <td>1125</td>\n      <td>6900.0</td>\n      <td>2</td>\n      <td>-3</td>\n      <td>1.2</td>\n      <td>1.8</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>681</th>\n      <td>HO2301-P-2750</td>\n      <td>上证50沽23年1月2750</td>\n      <td>1.0</td>\n      <td>-0.6</td>\n      <td>-37.5%</td>\n      <td>16</td>\n      <td>1800.0</td>\n      <td>1577</td>\n      <td>2750.0</td>\n      <td>2</td>\n      <td>-6</td>\n      <td>1.6</td>\n      <td>1.4</td>\n    </tr>\n    <tr>\n      <th>682</th>\n      <td>IO2301-P-4050</td>\n      <td>沪深300沽23年1月4050</td>\n      <td>1.6</td>\n      <td>-1.0</td>\n      <td>-38.46%</td>\n      <td>53</td>\n      <td>7580.0</td>\n      <td>2628</td>\n      <td>4050.0</td>\n      <td>2</td>\n      <td>-27</td>\n      <td>2.6</td>\n      <td>1.6</td>\n    </tr>\n    <tr>\n      <th>683</th>\n      <td>MO2301-P-5500</td>\n      <td>中证1000沽23年1月5500</td>\n      <td>0.2</td>\n      <td>-0.2</td>\n      <td>-50.0%</td>\n      <td>1</td>\n      <td>20.0</td>\n      <td>142</td>\n      <td>5500.0</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0.4</td>\n      <td>0.2</td>\n    </tr>\n    <tr>\n      <th>684</th>\n      <td>HO2301-P-2700</td>\n      <td>上证50沽23年1月2700</td>\n      <td>0.2</td>\n      <td>-0.2</td>\n      <td>-50.0%</td>\n      <td>20</td>\n      <td>400.0</td>\n      <td>2013</td>\n      <td>2700.0</td>\n      <td>2</td>\n      <td>-20</td>\n      <td>0.4</td>\n      <td>0.2</td>\n    </tr>\n    <tr>\n      <th>685</th>\n      <td>MO2301-P-6300</td>\n      <td>中证1000沽23年1月6300</td>\n      <td>0.6</td>\n      <td>-0.6</td>\n      <td>-50.0%</td>\n      <td>16</td>\n      <td>680.0</td>\n      <td>1918</td>\n      <td>6300.0</td>\n      <td>2</td>\n      <td>-2</td>\n      <td>1.2</td>\n      <td>0.4</td>\n    </tr>\n  </tbody>\n</table>\n<p>686 rows × 13 columns</p>\n</div>"
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "optshare.get_current_option(exchange_name = 'ccfex')"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 根据挂钩标的代码，返回当前挂钩该标的的期权信息"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "data": {
      "text/plain": "                代码               名称   最新价  涨跌额      涨跌幅  成交量        成交额   持仓量  \\\n0    IO2301-P-3800  沪深300沽23年1月3800   0.4  0.2   100.0%   19      760.0  3741   \n1    IO2302-P-3450  沪深300沽23年2月3450   2.2  0.6    37.5%    1      220.0   195   \n2    IO2302-P-3350  沪深300沽23年2月3350   1.8  0.4   28.57%   13     2120.0   253   \n3    IO2302-P-3650  沪深300沽23年2月3650   5.0  1.0    25.0%  147    72160.0  1621   \n4    IO2301-C-4350  沪深300购23年1月4350   1.2  0.2    20.0%    6      720.0   998   \n..             ...              ...   ...  ...      ...  ...        ...   ...   \n269  IO2303-P-3700  沪深300沽23年3月3700  10.8 -1.0   -8.47%   13    13900.0   845   \n270  IO2301-C-4200  沪深300购23年1月4200  10.6 -1.4  -11.67%  839  1071880.0  3372   \n271  IO2301-P-4100  沪深300沽23年1月4100   8.8 -1.2   -12.0%  610   459900.0  3205   \n272  IO2301-P-4050  沪深300沽23年1月4050   2.0 -0.6  -23.08%   84    13020.0  2646   \n273  IO2301-P-4000  沪深300沽23年1月4000   0.6 -0.2   -25.0%  147     7800.0  4270   \n\n        行权价  剩余日   日增    昨结    今开  \n0    3800.0    2   -1   0.2   0.4  \n1    3450.0   30    1   1.6   2.2  \n2    3350.0   30   13   1.4   1.6  \n3    3650.0   30  133   4.0   4.6  \n4    4350.0    2    5   1.0   1.2  \n..      ...  ...  ...   ...   ...  \n269  3700.0   58    2  11.8  10.6  \n270  4200.0    2  348  12.0  13.8  \n271  4100.0    2  102  10.0   8.0  \n272  4050.0    2   -9   2.6   1.6  \n273  4000.0    2  -44   0.8   0.6  \n\n[274 rows x 13 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>代码</th>\n      <th>名称</th>\n      <th>最新价</th>\n      <th>涨跌额</th>\n      <th>涨跌幅</th>\n      <th>成交量</th>\n      <th>成交额</th>\n      <th>持仓量</th>\n      <th>行权价</th>\n      <th>剩余日</th>\n      <th>日增</th>\n      <th>昨结</th>\n      <th>今开</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>IO2301-P-3800</td>\n      <td>沪深300沽23年1月3800</td>\n      <td>0.4</td>\n      <td>0.2</td>\n      <td>100.0%</td>\n      <td>19</td>\n      <td>760.0</td>\n      <td>3741</td>\n      <td>3800.0</td>\n      <td>2</td>\n      <td>-1</td>\n      <td>0.2</td>\n      <td>0.4</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>IO2302-P-3450</td>\n      <td>沪深300沽23年2月3450</td>\n      <td>2.2</td>\n      <td>0.6</td>\n      <td>37.5%</td>\n      <td>1</td>\n      <td>220.0</td>\n      <td>195</td>\n      <td>3450.0</td>\n      <td>30</td>\n      <td>1</td>\n      <td>1.6</td>\n      <td>2.2</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>IO2302-P-3350</td>\n      <td>沪深300沽23年2月3350</td>\n      <td>1.8</td>\n      <td>0.4</td>\n      <td>28.57%</td>\n      <td>13</td>\n      <td>2120.0</td>\n      <td>253</td>\n      <td>3350.0</td>\n      <td>30</td>\n      <td>13</td>\n      <td>1.4</td>\n      <td>1.6</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>IO2302-P-3650</td>\n      <td>沪深300沽23年2月3650</td>\n      <td>5.0</td>\n      <td>1.0</td>\n      <td>25.0%</td>\n      <td>147</td>\n      <td>72160.0</td>\n      <td>1621</td>\n      <td>3650.0</td>\n      <td>30</td>\n      <td>133</td>\n      <td>4.0</td>\n      <td>4.6</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>IO2301-C-4350</td>\n      <td>沪深300购23年1月4350</td>\n      <td>1.2</td>\n      <td>0.2</td>\n      <td>20.0%</td>\n      <td>6</td>\n      <td>720.0</td>\n      <td>998</td>\n      <td>4350.0</td>\n      <td>2</td>\n      <td>5</td>\n      <td>1.0</td>\n      <td>1.2</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>269</th>\n      <td>IO2303-P-3700</td>\n      <td>沪深300沽23年3月3700</td>\n      <td>10.8</td>\n      <td>-1.0</td>\n      <td>-8.47%</td>\n      <td>13</td>\n      <td>13900.0</td>\n      <td>845</td>\n      <td>3700.0</td>\n      <td>58</td>\n      <td>2</td>\n      <td>11.8</td>\n      <td>10.6</td>\n    </tr>\n    <tr>\n      <th>270</th>\n      <td>IO2301-C-4200</td>\n      <td>沪深300购23年1月4200</td>\n      <td>10.6</td>\n      <td>-1.4</td>\n      <td>-11.67%</td>\n      <td>839</td>\n      <td>1071880.0</td>\n      <td>3372</td>\n      <td>4200.0</td>\n      <td>2</td>\n      <td>348</td>\n      <td>12.0</td>\n      <td>13.8</td>\n    </tr>\n    <tr>\n      <th>271</th>\n      <td>IO2301-P-4100</td>\n      <td>沪深300沽23年1月4100</td>\n      <td>8.8</td>\n      <td>-1.2</td>\n      <td>-12.0%</td>\n      <td>610</td>\n      <td>459900.0</td>\n      <td>3205</td>\n      <td>4100.0</td>\n      <td>2</td>\n      <td>102</td>\n      <td>10.0</td>\n      <td>8.0</td>\n    </tr>\n    <tr>\n      <th>272</th>\n      <td>IO2301-P-4050</td>\n      <td>沪深300沽23年1月4050</td>\n      <td>2.0</td>\n      <td>-0.6</td>\n      <td>-23.08%</td>\n      <td>84</td>\n      <td>13020.0</td>\n      <td>2646</td>\n      <td>4050.0</td>\n      <td>2</td>\n      <td>-9</td>\n      <td>2.6</td>\n      <td>1.6</td>\n    </tr>\n    <tr>\n      <th>273</th>\n      <td>IO2301-P-4000</td>\n      <td>沪深300沽23年1月4000</td>\n      <td>0.6</td>\n      <td>-0.2</td>\n      <td>-25.0%</td>\n      <td>147</td>\n      <td>7800.0</td>\n      <td>4270</td>\n      <td>4000.0</td>\n      <td>2</td>\n      <td>-44</td>\n      <td>0.8</td>\n      <td>0.6</td>\n    </tr>\n  </tbody>\n</table>\n<p>274 rows × 13 columns</p>\n</div>"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 权益类\n",
    "optshare.get_current_option(underlying_code ='000300')"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "data": {
      "text/plain": "               代码              名称     最新价     涨跌额      涨跌幅   成交量        成交额  \\\n0    cu2304P52000  沪铜23年04月沽52000    36.0    34.0  1700.0%     2     4980.0   \n1    cu2303P55000  沪铜23年03月沽55000    20.0    18.0   900.0%    24     4780.0   \n2    cu2308P61000  沪铜23年08月沽61000  7862.0  6834.0  664.79%     0    39310.0   \n3    cu2304P54000  沪铜23年04月沽54000    44.0    38.0  633.33%     0      880.0   \n4    cu2303P50000  沪铜23年03月沽50000    14.0    12.0   600.0%     0      210.0   \n..            ...             ...     ...     ...      ...   ...        ...   \n395  cu2307P54000  沪铜23年07月沽54000   180.0  -576.0  -76.19%     3     8480.0   \n396  cu2302P70000  沪铜23年02月沽70000   348.0 -1238.0  -78.06%  1002  4714410.0   \n397  cu2302P67000  沪铜23年02月沽67000     2.0   -38.0   -95.0%  1242    76250.0   \n398  cu2302P69000  沪铜23年02月沽69000    16.0  -742.0  -97.89%  4670  8800660.0   \n399  cu2302P68000  沪铜23年02月沽68000     2.0  -234.0  -99.15%  3413  1267520.0   \n\n      持仓量  行权价  剩余日    日增      昨结      今开  \n0     568  NaN  NaN     0     2.0    30.0  \n1     658  NaN  NaN   -25     2.0    34.0  \n2       8  NaN  NaN    -1  1028.0  7862.0  \n3     161  NaN  NaN     4     6.0    46.0  \n4     267  NaN  NaN    -3     2.0    14.0  \n..    ...  ...  ...   ...     ...     ...  \n395    33  NaN  NaN     6   756.0   198.0  \n396   658  NaN  NaN   541  1586.0  1210.0  \n397  1226  NaN  NaN -1292    40.0     8.0  \n398  2411  NaN  NaN  2161   758.0   460.0  \n399  2173  NaN  NaN  -257   236.0    62.0  \n\n[400 rows x 13 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>代码</th>\n      <th>名称</th>\n      <th>最新价</th>\n      <th>涨跌额</th>\n      <th>涨跌幅</th>\n      <th>成交量</th>\n      <th>成交额</th>\n      <th>持仓量</th>\n      <th>行权价</th>\n      <th>剩余日</th>\n      <th>日增</th>\n      <th>昨结</th>\n      <th>今开</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>cu2304P52000</td>\n      <td>沪铜23年04月沽52000</td>\n      <td>36.0</td>\n      <td>34.0</td>\n      <td>1700.0%</td>\n      <td>2</td>\n      <td>4980.0</td>\n      <td>568</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>0</td>\n      <td>2.0</td>\n      <td>30.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>cu2303P55000</td>\n      <td>沪铜23年03月沽55000</td>\n      <td>20.0</td>\n      <td>18.0</td>\n      <td>900.0%</td>\n      <td>24</td>\n      <td>4780.0</td>\n      <td>658</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>-25</td>\n      <td>2.0</td>\n      <td>34.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>cu2308P61000</td>\n      <td>沪铜23年08月沽61000</td>\n      <td>7862.0</td>\n      <td>6834.0</td>\n      <td>664.79%</td>\n      <td>0</td>\n      <td>39310.0</td>\n      <td>8</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>-1</td>\n      <td>1028.0</td>\n      <td>7862.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>cu2304P54000</td>\n      <td>沪铜23年04月沽54000</td>\n      <td>44.0</td>\n      <td>38.0</td>\n      <td>633.33%</td>\n      <td>0</td>\n      <td>880.0</td>\n      <td>161</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>4</td>\n      <td>6.0</td>\n      <td>46.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>cu2303P50000</td>\n      <td>沪铜23年03月沽50000</td>\n      <td>14.0</td>\n      <td>12.0</td>\n      <td>600.0%</td>\n      <td>0</td>\n      <td>210.0</td>\n      <td>267</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>-3</td>\n      <td>2.0</td>\n      <td>14.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>395</th>\n      <td>cu2307P54000</td>\n      <td>沪铜23年07月沽54000</td>\n      <td>180.0</td>\n      <td>-576.0</td>\n      <td>-76.19%</td>\n      <td>3</td>\n      <td>8480.0</td>\n      <td>33</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>6</td>\n      <td>756.0</td>\n      <td>198.0</td>\n    </tr>\n    <tr>\n      <th>396</th>\n      <td>cu2302P70000</td>\n      <td>沪铜23年02月沽70000</td>\n      <td>348.0</td>\n      <td>-1238.0</td>\n      <td>-78.06%</td>\n      <td>1002</td>\n      <td>4714410.0</td>\n      <td>658</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>541</td>\n      <td>1586.0</td>\n      <td>1210.0</td>\n    </tr>\n    <tr>\n      <th>397</th>\n      <td>cu2302P67000</td>\n      <td>沪铜23年02月沽67000</td>\n      <td>2.0</td>\n      <td>-38.0</td>\n      <td>-95.0%</td>\n      <td>1242</td>\n      <td>76250.0</td>\n      <td>1226</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>-1292</td>\n      <td>40.0</td>\n      <td>8.0</td>\n    </tr>\n    <tr>\n      <th>398</th>\n      <td>cu2302P69000</td>\n      <td>沪铜23年02月沽69000</td>\n      <td>16.0</td>\n      <td>-742.0</td>\n      <td>-97.89%</td>\n      <td>4670</td>\n      <td>8800660.0</td>\n      <td>2411</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>2161</td>\n      <td>758.0</td>\n      <td>460.0</td>\n    </tr>\n    <tr>\n      <th>399</th>\n      <td>cu2302P68000</td>\n      <td>沪铜23年02月沽68000</td>\n      <td>2.0</td>\n      <td>-234.0</td>\n      <td>-99.15%</td>\n      <td>3413</td>\n      <td>1267520.0</td>\n      <td>2173</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>-257</td>\n      <td>236.0</td>\n      <td>62.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>400 rows × 13 columns</p>\n</div>"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 商品类，以铜期权为例\n",
    "optshare.get_current_option(underlying_code ='cu')"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## Option information"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 支持的交易所名称以及字母简写"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "outputs": [
    {
     "data": {
      "text/plain": "  交易市场名称  交易市场\n0    sse   上交所\n1   szse   深交所\n2  cffex   中金所\n3   shfe   上期所\n4    dce   大商所\n5   czce   郑商所\n6    ine  上期能源",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>交易市场名称</th>\n      <th>交易市场</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>sse</td>\n      <td>上交所</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>szse</td>\n      <td>深交所</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>cffex</td>\n      <td>中金所</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>shfe</td>\n      <td>上期所</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>czce</td>\n      <td>郑商所</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>ine</td>\n      <td>上期能源</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "optshare.get_exchange_info()"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 支持的期权品种"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "outputs": [
    {
     "data": {
      "text/plain": "      标的代码        期权名称\n0   510050   上证50ETF期权\n1   510300  沪深300ETF期权\n2   510500  中证500ETF期权\n3   159919  沪深300ETF期权\n4   159922  中证500ETF期权\n5   159915    创业板ETF期权\n6   000300   沪深300股指期权\n7   000852  中证1000股指期权\n8   000016    上证50股指期权\n9       cu         铜期权\n10      al         铝期权\n11      zn         锌期权\n12      rb       螺纹钢期权\n13      au        黄金期权\n14      ag        白银期权\n15      ru        天胶期权\n16       m        豆粕期权\n17       c        玉米期权\n18       i       铁矿石期权\n19      pg   液化石油天然气期权\n20       l       聚乙烯期权\n21       v      聚氯乙烯期权\n22      pp       聚丙烯期权\n23       p       棕榈油期权\n24       a     黄大豆1号期权\n25       b     黄大豆2号期权\n26       y        豆油期权\n27      SR        白糖期权\n28      CF        棉花期权\n29      TA       PTA期权\n30      MA        甲醇期权\n31      RM       菜籽粕期权\n32      OI       菜籽油期权\n33      PK        花生期权\n34      sc        原油期权",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>标的代码</th>\n      <th>期权名称</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>510050</td>\n      <td>上证50ETF期权</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>510300</td>\n      <td>沪深300ETF期权</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>510500</td>\n      <td>中证500ETF期权</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>159919</td>\n      <td>沪深300ETF期权</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>159922</td>\n      <td>中证500ETF期权</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>159915</td>\n      <td>创业板ETF期权</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>000300</td>\n      <td>沪深300股指期权</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>000852</td>\n      <td>中证1000股指期权</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>000016</td>\n      <td>上证50股指期权</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>cu</td>\n      <td>铜期权</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>al</td>\n      <td>铝期权</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>zn</td>\n      <td>锌期权</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>rb</td>\n      <td>螺纹钢期权</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>au</td>\n      <td>黄金期权</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>ag</td>\n      <td>白银期权</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>ru</td>\n      <td>天胶期权</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>m</td>\n      <td>豆粕期权</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>c</td>\n      <td>玉米期权</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>i</td>\n      <td>铁矿石期权</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>pg</td>\n      <td>液化石油天然气期权</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>l</td>\n      <td>聚乙烯期权</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>v</td>\n      <td>聚氯乙烯期权</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>pp</td>\n      <td>聚丙烯期权</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>p</td>\n      <td>棕榈油期权</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>a</td>\n      <td>黄大豆1号期权</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>b</td>\n      <td>黄大豆2号期权</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>y</td>\n      <td>豆油期权</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>SR</td>\n      <td>白糖期权</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>CF</td>\n      <td>棉花期权</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>TA</td>\n      <td>PTA期权</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>MA</td>\n      <td>甲醇期权</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>RM</td>\n      <td>菜籽粕期权</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>OI</td>\n      <td>菜籽油期权</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>PK</td>\n      <td>花生期权</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>sc</td>\n      <td>原油期权</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "optshare.get_option_info()"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 根据交易所名称，返回相应的期权信息\n"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "data": {
      "text/plain": "      标的代码        期权名称 交易市场名称  交易市场\n0   510050   上证50ETF期权    sse   上交所\n1   510300  沪深300ETF期权    sse   上交所\n2   510500  中证500ETF期权    sse   上交所\n3   159919  沪深300ETF期权   szse   深交所\n4   159922  中证500ETF期权   szse   深交所\n5   159915    创业板ETF期权   szse   深交所\n6   000300   沪深300股指期权  cffex   中金所\n7   000852  中证1000股指期权  cffex   中金所\n8   000016    上证50股指期权  cffex   中金所\n9       cu         铜期权   shfe   上期所\n10      al         铝期权   shfe   上期所\n11      zn         锌期权   shfe   上期所\n12      rb       螺纹钢期权   shfe   上期所\n13      au        黄金期权   shfe   上期所\n14      ag        白银期权   shfe   上期所\n15      ru        天胶期权   shfe   上期所\n16       m        豆粕期权    dce   大商所\n17       c        玉米期权    dce   大商所\n18       i       铁矿石期权    dce   大商所\n19      pg   液化石油天然气期权    dce   大商所\n20       l       聚乙烯期权    dce   大商所\n21       v      聚氯乙烯期权    dce   大商所\n22      pp       聚丙烯期权    dce   大商所\n23       p       棕榈油期权    dce   大商所\n24       a     黄大豆1号期权    dce   大商所\n25       b     黄大豆2号期权    dce   大商所\n26       y        豆油期权    dce   大商所\n27      SR        白糖期权   czce   郑商所\n28      CF        棉花期权   czce   郑商所\n29      TA       PTA期权   czce   郑商所\n30      MA        甲醇期权   czce   郑商所\n31      RM       菜籽粕期权   czce   郑商所\n32      OI       菜籽油期权   czce   郑商所\n33      PK        花生期权   czce   郑商所\n34      sc        原油期权    ine  上期能源",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>标的代码</th>\n      <th>期权名称</th>\n      <th>交易市场名称</th>\n      <th>交易市场</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>510050</td>\n      <td>上证50ETF期权</td>\n      <td>sse</td>\n      <td>上交所</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>510300</td>\n      <td>沪深300ETF期权</td>\n      <td>sse</td>\n      <td>上交所</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>510500</td>\n      <td>中证500ETF期权</td>\n      <td>sse</td>\n      <td>上交所</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>159919</td>\n      <td>沪深300ETF期权</td>\n      <td>szse</td>\n      <td>深交所</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>159922</td>\n      <td>中证500ETF期权</td>\n      <td>szse</td>\n      <td>深交所</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>159915</td>\n      <td>创业板ETF期权</td>\n      <td>szse</td>\n      <td>深交所</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>000300</td>\n      <td>沪深300股指期权</td>\n      <td>cffex</td>\n      <td>中金所</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>000852</td>\n      <td>中证1000股指期权</td>\n      <td>cffex</td>\n      <td>中金所</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>000016</td>\n      <td>上证50股指期权</td>\n      <td>cffex</td>\n      <td>中金所</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>cu</td>\n      <td>铜期权</td>\n      <td>shfe</td>\n      <td>上期所</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>al</td>\n      <td>铝期权</td>\n      <td>shfe</td>\n      <td>上期所</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>zn</td>\n      <td>锌期权</td>\n      <td>shfe</td>\n      <td>上期所</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>rb</td>\n      <td>螺纹钢期权</td>\n      <td>shfe</td>\n      <td>上期所</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>au</td>\n      <td>黄金期权</td>\n      <td>shfe</td>\n      <td>上期所</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>ag</td>\n      <td>白银期权</td>\n      <td>shfe</td>\n      <td>上期所</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>ru</td>\n      <td>天胶期权</td>\n      <td>shfe</td>\n      <td>上期所</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>m</td>\n      <td>豆粕期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>c</td>\n      <td>玉米期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>i</td>\n      <td>铁矿石期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>pg</td>\n      <td>液化石油天然气期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>l</td>\n      <td>聚乙烯期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>v</td>\n      <td>聚氯乙烯期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>pp</td>\n      <td>聚丙烯期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>p</td>\n      <td>棕榈油期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>a</td>\n      <td>黄大豆1号期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>b</td>\n      <td>黄大豆2号期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>y</td>\n      <td>豆油期权</td>\n      <td>dce</td>\n      <td>大商所</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>SR</td>\n      <td>白糖期权</td>\n      <td>czce</td>\n      <td>郑商所</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>CF</td>\n      <td>棉花期权</td>\n      <td>czce</td>\n      <td>郑商所</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>TA</td>\n      <td>PTA期权</td>\n      <td>czce</td>\n      <td>郑商所</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>MA</td>\n      <td>甲醇期权</td>\n      <td>czce</td>\n      <td>郑商所</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>RM</td>\n      <td>菜籽粕期权</td>\n      <td>czce</td>\n      <td>郑商所</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>OI</td>\n      <td>菜籽油期权</td>\n      <td>czce</td>\n      <td>郑商所</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>PK</td>\n      <td>花生期权</td>\n      <td>czce</td>\n      <td>郑商所</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>sc</td>\n      <td>原油期权</td>\n      <td>ine</td>\n      <td>上期能源</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "optshare.get_meta_data()"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 根据交易所名称，返回相应的期权信息"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "outputs": [
    {
     "data": {
      "text/plain": "     标的代码        期权名称 交易市场名称 交易市场\n6  000300   沪深300股指期权  cffex  中金所\n7  000852  中证1000股指期权  cffex  中金所\n8  000016    上证50股指期权  cffex  中金所",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>标的代码</th>\n      <th>期权名称</th>\n      <th>交易市场名称</th>\n      <th>交易市场</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>6</th>\n      <td>000300</td>\n      <td>沪深300股指期权</td>\n      <td>cffex</td>\n      <td>中金所</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>000852</td>\n      <td>中证1000股指期权</td>\n      <td>cffex</td>\n      <td>中金所</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>000016</td>\n      <td>上证50股指期权</td>\n      <td>cffex</td>\n      <td>中金所</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "optshare.get_meta_data(exchange_name = 'cffex')"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
